package com.levi.StrategyPattern.Strategy;

import com.levi.StrategyPattern.CashSuper;

/**
 * @author Levi
 * @description :  返利收费的策略类
 * @since 2022/8/31 15:30
 */

public class CashReturn extends CashSuper {
    //    返利条件
    private double moneyCondition = 0.0d;
    //    返利
    private double moneyReturn = 0.0d;

    //    构造函数
    public CashReturn(String moneyCondition, String moneyReturn) {
        this.moneyCondition = Double.parseDouble(moneyCondition);
        this.moneyReturn = Double.parseDouble(moneyReturn);
    }

    @Override
    public double acceptCash(double money) {
        double result = money;
        if (money >= moneyCondition) {
            result = money - (int) (money / moneyCondition) * moneyReturn;
        }
        return result;
    }
}
